<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>提取一行作为枚举数组</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.pg-fetch-row" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">pg_fetch_row</h1>
    <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">pg_fetch_row</span> &mdash; <span class="dc-title">提取一行作为枚举数组</span></p>

   </div>
 
 <div class="refsect1 description" id="refsect1-function.pg-fetch-row-description">
  <h3 class="title">说明</h3>
     <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_fetch_row</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$row</code></span>
   
  ] ) : <span class="type">array</span></div>

    <p class="para rdfs-comment">
     <span class="function"><strong>pg_fetch_row()</strong></span> 根据指定的 <code class="parameter">result</code> 资源提取一行数据（记录）作为数组返回。每个得到的列依次存放在数组中，从偏移量 0 开始。
    </p>
    <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数将 NULL 字段设置为 PHP <strong><code>NULL</code></strong> 值。</span></p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-fetch-row-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">result</code></dt>

     <dd>

      <p class="para">
       PostgreSQL query result resource, returned by <span class="function"><a href="pg_query.html" class="function">pg_query()</a></span>,
       <span class="function"><a href="pg_query_params.html" class="function">pg_query_params()</a></span> or <span class="function"><a href="pg_execute.html" class="function">pg_execute()</a></span>
       (among others).
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">row</code></dt>

     <dd>

      <p class="para">
       Row number in result to fetch. Rows are numbered from 0 upwards. If
       omitted or <strong><code>NULL</code></strong>, the next row is fetched.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-fetch-row-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   An <span class="type"><a href="language.types.array.html" class="type array">array</a></span>, indexed from 0 upwards, with each value
   represented as a <span class="type"><a href="language.types.string.html" class="type string">string</a></span>.  Database <em>NULL</em>
   values are returned as <strong><code>NULL</code></strong>.
  </p>
  <p class="para">
   返回的数组和提取的行相一致。如果没有更多行 <code class="parameter">row</code> 可提取，则返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-fetch-row-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.1.0</td>
       <td>
        参数 <code class="parameter">row</code> 成为可选参数。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-fetch-row-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2492">
    <p><strong>Example #1 <span class="function"><strong>pg_fetch_row()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"An&nbsp;error&nbsp;occured.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"SELECT&nbsp;author,&nbsp;email&nbsp;FROM&nbsp;authors"</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"An&nbsp;error&nbsp;occured.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;exit;<br />}<br /><br />while&nbsp;(</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_fetch_row</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Author:&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]</span><span style="color: #DD0000">&nbsp;&nbsp;E-mail:&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />}<br />&nbsp;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pg-fetch-row-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="pg_query.html" class="function" rel="rdfs-seeAlso">pg_query()</a> - 执行查询</span></li>
    <li class="member"><span class="function"><a href="pg_fetch_array.html" class="function" rel="rdfs-seeAlso">pg_fetch_array()</a> - 提取一行作为数组</span></li>
    <li class="member"><span class="function"><a href="pg_fetch_object.html" class="function" rel="rdfs-seeAlso">pg_fetch_object()</a> - 提取一行作为对象</span></li>
    <li class="member"><span class="function"><a href="pg_fetch_result.html" class="function" rel="rdfs-seeAlso">pg_fetch_result()</a> - 从结果资源中返回值</span></li>
   </ul>
  </p>
 </div>

  </div></div></div></body></html>